<?php

class OutputStream
{
   private $_stream;

   function __construct()
   {
      $this->_stream = array();
   }

   public function flush()
   {
      foreach($this->_stream as $line)
      {
         echo $line."\n";
      }
   }

   public function flushAsHTML()
   {      
      foreach($this->_stream as $line)
      {
         echo $line."<br>";
      }
   }

   public function addLine($line)
   {
      $this->_stream[] = $line;
   }

   public function clear()
   {
      unset($this->_stream);
      $this->_stream = array();
   }

   public function close()
   {
      $this->clear();
      unset($this);
   }

}

?>